/**
 * 机票服务数据交互统一入口
 */
'use strict';
var flight = {};

//机票查询
//params= fromCityCode:出发城市编码，toCityCode:到达城市编码，fromDate:出发时间，sort：date_early，isFilter：是否过滤
flight.getFlightList = function (params,success,fail) {
  this.axios.get('flight/search/flightQuery.json',{
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//机票城市搜索查询
flight.flightCityList = function (params,success,fail) {
  this.axios.get('flight/booking/cityList.json',{
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//机票验价
flight.checkPrice = function (params, success, fail) {
  this.axios.get('flight/search/checkPrice.json', {
    params: params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//创建订单
flight.createOrder = function (data, success, fail) {
  this.axios.post('flight/booking/createOrder.json',data).then(res => {
    success(res.data);
  }).catch(fail);
};

// 退订机票
flight.refundTicket = function (data, success, fail) {
  this.axios.post('flight/order/refundTicket.json',data, {
    headers:{'Content-Type':'multipart/form-data'}
  }).then(res => {
    success(res.data);
  }).catch(fail);
}

// 预订机票
flight.flightBookingTicket = function (params, success, fail) {
  this.axios.get('flight/booking/index.json',{
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//航班所有舱位最优退改签
flight.flighOptimalRule = function (params, success, fail) {
  this.axios.get('flight/search/optimalRule.json',{
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//舱位退改签详情信息
flight.flightRefundChangeDetail = function (params, success, fail) {
  this.axios.get('flight/search/refundChangeDetail.json',{
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//增加乘机人 列表选择 从部门列表中选择拿到数据
flight.flightGetPersonalInfo = function (params, success, fail) {
  this.axios.get('flight/booking/findByOrgId.json', {
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//机票价格变动重新请求
flight.flightPriceChange = function (params, success, fail) {
  this.axios.get('flight/return/booking/index.json', {
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};

//机票【往返程】填单页创建订单
flight.flightReturnCreatedOrder = function (params, success, fail) {
  this.axios.get('flight/return/booking/createOrder.json', {
    params:params
  }).then(res => {
    success(res.data);
  }).catch(fail);
};



export default flight;
